<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="采砂场统计分析">

    <!--suppress ALL -->
    <form id="searchForm" class="form-panel"  action="/rest/manage/dataAnalyse/selectSandpitPage" method="get">
        <ul class="panel-content">
            <li style="height: auto;overflow: hidden">
                <div class="control-group controls span7">
                    <label class=" pull-left">
                        开始时间：
                    </label>
                    <div class="pull-left ">
                        <input name="startDate" id="startDate" class="input-small  calendar calendar-time  input-pad startDate" type="text">
                    </div>
                </div>
                <div class="control-group controls span7">
                    <label class=" pull-left">
                        结束时间：
                    </label>
                    <div class="pull-left">
                        <input name="endDate" id="endDate" class="input-small calendar calendar-time  input-pad endDate" type="text">
                    </div>
                </div>
                <div class="form-actions  controls">
                    <button type="submit" class="button button-success">
                        查询
                    </button>
                </div>
            </li>
        </ul>
    </form>
    <div id="grid"></div>
<script>
    var Grid = BUI.Grid,
            Calendar = BUI.Calendar,
            datePicker = new Calendar.DatePicker({
                trigger:'.calendar-time',
                dateMask :'yyyy-mm-dd HH:MM:ss',
                showTime:true,
                autoRender: true
            }),
            Store = BUI.Data.Store,
            columns = [
                {title : '采砂场名称',elCls: 'center',  dataIndex :'sandpit', width:'20%'},
                {title : '车辆总次数',elCls: 'center',  dataIndex :'recordAmount', width:'20%'},
                {title : '货物总重量(KG)',elCls: 'center',  dataIndex :'sandWeightAmount', width:'20%'},
                {title : '总金额（RMB）',elCls: 'center', dataIndex :'moneyAmount', width:'20%'},
                {title : '操作',elCls: 'center',dataIndex :'sandpit', width:'20%',renderer:function (value){
                        var sandpit=value=='马庄'?0:1;
                    return '<a href="javascript:godetail(' + sandpit + ')">查看详细记录</a>';
                    } }
            ];

    var store = new Store({
                url : '/rest/manage/dataAnalyse/selectSandpitPage',
                autoLoad:true, //自动加载数据
                params : { //配置初始请求的参数
                    length : '10'
                },
                pageSize:10,	// 配置分页数目
                root : 'list',
                totalProperty : 'total'
            }),
            grid = new Grid.Grid({
                render:'#grid',
                columns : columns,
                loadMask: true, //加载数据时显示屏蔽层
                store: store,
                // 底部工具栏
                bbar:{
                    pagingBar:true
                }
            });

    grid.render();
    //查询框
    var form = new BUI.Form.HForm({
        srcNode: '#searchForm'
    }).render();

    form.on('beforesubmit', function (ev) {
        var obj = form.serializeToObject();
        obj.start = 0; //返回第一页
        store.load(obj);
        return false;
    });
    function godetail(sandpit) {
        var endDate=$('#endDate').val();
        var startDate=$('#startDate').val();
       window.location.href='${basepath}/rest/manage/weightrecord/toSandDetail?endDate='+endDate+'&startDate='+startDate+'&sandpit='+sandpit;
    }
</script>

</@page.pageBase>
